package cst.a921sxh.zyfypt_921sxh;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment1} subclass.
 */
public class Fragment1 extends Fragment {
    private RecyclerView recyclerView;
    private ArticleAdapter adapter;
    private List<ArticleBean> list;
    private RecyclerView.LayoutManager layoutManager;
    private sxhListener<List<ArticleBean>> listener;
    private ResModel model;
  //  private SharedPreferences sp;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

       View view = inflater.inflate(R.layout.fragment1,container,false);
       recyclerView=(RecyclerView)view.findViewById(R.id.article_rec);
        adapter=new ArticleAdapter(getActivity());
        list=new ArrayList<ArticleBean>();
        layoutManager=new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
        listener=new sxhListener<List<ArticleBean>>() {
            @Override
            public void onResponse(List<ArticleBean> l) {
                adapter.setList(l);
            }

            @Override
            public void onFail(String msg) {

            }
        };
       model=new ResModel("gson");
        model.getList("article",1,listener);
        return view;
    }

}
